import pathway as pw
from application.db.mysql_db.nsfc.NsfcInfoTypeDict import NsfcInfoTypeDict


class NsfcInfoTypeDictSchema(pw.Schema):
    info_type_id: str
    info_type_name: str


class NsfcInfoTypeDictRead(pw.io.python.ConnectorSubject):
    
    def run(self):
        select_list = NsfcInfoTypeDict.select().dicts()
        for doc in select_list:
            doc = self.transform(doc)
            self.next(**doc)
    
    def transform(self, transform_data):
        transform_data = {k: v for k, v in transform_data.items()
                          if v is not None and v != {}}
        
        return transform_data